<template>
  <el-select style="width: 100%" v-model="userName" clearable filterable placeholder="请选择管理员"
             @change="selectSysUser" value-key="id">
    <el-option
      v-for="item in sysUserList"
      :key="item.id"
      :label="item.nickname"
      :value="item">
    </el-option>
  </el-select>
</template>

<script>
import {list} from '@/api/sysUser'
import utils from '../../utils/utils.js'
export default{
  data(){
    return{
      query:{
        userId:''
      },
      sysUserList:[],
      userName:''
    }
  },
  props:{
    queryTitle:{
      type:String,
      value:'请选择管理员'
    },
    operatorName:{
      type:String,
      value:''
    }
  },
  created() {
    this.userName=this.operatorName
    this.loadSysUser()
  },
  methods:{
    selectSysUser(data) {
      console.log(data)
      if(!utils.isNull(data)){
        this.query.userId = data.id
        this.query.name = data.nickname
      }else{
        this.query.userId = ''
        this.query.name = ''
      }
      this.$emit('queryUserClick',this.query)
    },
    //  送货员
    loadSysUser() {
      var _this = this
      let params = new URLSearchParams();
      list(params).then(response => {
        console.log(response);
        _this.sysUserList = response.data.data
        console.log(_this.sysUserList,"user");

      }).catch(error => {
        console.log('error!!')
      });
    }
  }
}
</script>

<style>
</style>

